import React from 'react';
import PropTypes from 'prop-types';

import './roadInfo.scoped.less';

function RoadInfo(props) {
  return (
    <div className={`RoadInfo ${props.className}`} style={props.style}>
      {props.list.map((item, index) => {
        return (
          <div className="item" key={item[props.filedKey] || index}>
            {props.renderText ? props.renderText(item) : item[props.filed]}
          </div>
        );
      })}
    </div>
  );
}

RoadInfo.propTypes = {
  list: PropTypes.array,
  filed: PropTypes.string,
  filedKey: PropTypes.string,
  renderText: PropTypes.func,
};

RoadInfo.defaultProps = {
  list: [],
  filed: 'text',
  filedKey: 'code',
  renderText: '',
};

export default RoadInfo;
